﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using LeanCloud;

//赋值给Editor 和 Detail 场景中的UI中的 Label 或者 TextField
public class AssignValue : MonoBehaviour {

    public Text SuYuanMa;
    public Text ChanPinMing;
    public Text FangWeiQianZhui;
    public Text FangWeiMa;
    public string QRCodeURL;
    public string ZhengShuURL;
    public Text PeiLiao;
    public Text JingZhong;
    public Text ShengChanRiQi;
    public Text JieDongRiQi;
    public Text ShengChanShang;
    public Text DiZhi;
    public Text XuKeZhengHao;
    public Text GuoMinTiShi;
    public Text GongYingShangMing;
    public Text PiCiHao;
    public Text ShengChanDiZhi;
    public Text ZhiJianBaoGao;
    public Text RuKuShiJian;
    public Text ChuKuShiJian;
    public Text WuLiuXinXi;
    public Text WuLiuGongSi;
    public Text CheLiangXinXi;
    public Text JiaShiYuan;

    public InputField MyTest;

    IEnumerable<AVObject> shops;
    bool start = false;

    
    // Use this for initialization
    void Start () {
        Debug.Log("开始查询 按照点击的当前的Toggle对应的ObjectId:" + StaticVariable.currentObjectId);
        AVQuery<AVObject> query1 = new AVQuery<AVObject>("GameEquipBag").WhereEqualTo("objectId", StaticVariable.currentObjectId);
        query1.FindAsync().ContinueWith(t => {
            shops = t.Result;
            start = true;
            
        });

    
    }




    // Update is called once per frame
    void Update () {
        if (start)
        {
            start = false;
            //用id查询的话 shops中永远只有1条数据  所以 foreach只循环一次
            foreach (AVObject equipment in shops)
            {
                string SYM = equipment.Get<string>("shop_id");
                string Name = equipment.Get<string>("shop_name");
                string FWMQZ = equipment.Get<string>("shop_Firstnum");
                string FWM = equipment.Get<string>("shop_num");
                string PL = equipment.Get<string>("shop_batching");
                string JZL = equipment.Get<string>("shop_weight");
                string SCS = equipment.Get<string>("shop_production");
                string DZ = equipment.Get<string>("shop_address");
                string SCXKZBH = equipment.Get<string>("shop_shengchancode");
                string GMTS = equipment.Get<string>("shop_guomin");

                StaticVariable.currentShopId = SYM;
                SuYuanMa.gameObject.GetComponentInParent<InputField>().text = SYM;
                ChanPinMing.gameObject.GetComponentInParent<InputField>().text = Name;
                FangWeiQianZhui.gameObject.GetComponentInParent<InputField>().text = FWMQZ;
                FangWeiMa.gameObject.GetComponentInParent<InputField>().text = FWM;
                PeiLiao.gameObject.GetComponentInParent<InputField>().text = PL;
                JingZhong.gameObject.GetComponentInParent<InputField>().text = JZL;

                Debug.Log("我的查询结果：" + SYM + Name + FWMQZ);
                MyTest.text = SYM + Name + FWMQZ;

            }
        }//end if(start)

        if (Input.GetKeyDown(KeyCode.Space)) {
            Debug.Log("Space按下");
            MyTest.text = "AAAAAAAAA";
        }

	}
}
